package enumerated.tij;

import static util.Print.print;
import static util.Print.printnb;

import io.tij.OSExecute;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.Set;

import util.Constants;


enum Explore {
	HEAR, THERE
}

public class Reflection {

	public static Set<String> analyze(Class<?> enumClass) {
		print("Interfaces: ");
		for (Type type : enumClass.getGenericInterfaces())
			print(type);

		print("Base: ");
		print(enumClass.getSuperclass());

		print("Mehods: ");
		Set<String> methods = new HashSet<String>();
		for (Method method : enumClass.getMethods()) {
			methods.add(method.getName());
		}
		print(methods);

		return methods;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Set<String> exploreMethods = analyze(Explore.class);
		Set<String> enumMethods = analyze(Enum.class);
		
		print("Explore.containsAll(Enum)? "
				+ exploreMethods.containsAll(enumMethods));
		printnb("Explore.removeAll(Enum): ");
		exploreMethods.removeAll(enumMethods);
		print(exploreMethods);
		
		print("Decompile Explore: ");
		OSExecute.command("javap " + Constants.BIN_DIR + Reflection.class.getPackage().getName() + Constants.FILE_SEPARATOR + "Explore");
	}
}
/*
Interfaces: 
Base: 
class java.lang.Enum
Mehods: 
[hashCode, getClass, values, toString, ordinal, compareTo, notifyAll, getDeclaringClass, equals, valueOf, wait, name, notify]
Interfaces: 
java.lang.Comparable<E>
interface java.io.Serializable
Base: 
class java.lang.Object
Mehods: 
[compareTo, hashCode, notifyAll, getClass, getDeclaringClass, toString, equals, valueOf, wait, ordinal, name, notify]
Explore.containsAll(Enum)? true
Explore.removeAll(Enum): [values]
Decompile Explore: 
Compiled from "Reflection.java"
final class enumerated.Explore extends java.lang.Enum{
    public static final enumerated.Explore HEAR;
    public static final enumerated.Explore THERE;
    static {};
    public static enumerated.Explore[] values();
    public static enumerated.Explore valueOf(java.lang.String);
}

 */
